//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using CA = ComponentArt.Web.UI;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;

namespace CommunityServer.ControlPanel.Photos
{
	/// <summary>
	/// Summary description for GallerySwitchPage.
	/// </summary>
	public class GallerySwitchPage : BaseGalleryPage
	{

		#region Child Controls

		protected MPContent DescriptionRegion;
		protected MPContent TaskRegion;
		protected PanelTabControl PanelTabControl1;
		protected MPContainer MPContainer;
		protected DropDownList PageSize;
		protected ResourceControl SectionDescription;
		protected ResourceControl Section_Sub_Description;
		protected ControlPanelSelectedNavigation SelectedNavigation1;
		protected MPContent PanelDescription;
		protected ResourceControl PanelDescriptionResource;
		protected ResourceControl Resourcecontrol1;
		protected Hyperlink HyperLink1;
		protected MPContent TopLeft;
		protected ControlPanelNavigationSidebar Controlpanelnavigationsidebar1;
		protected MPContent PanelNavigation;
		protected CA.Grid Grid1;
		protected CommunityServer.ControlPanel.Controls.StatusMessage Status;
		protected SwitchControl SectionList1;

		#endregion
	
		private void Page_Load(object sender, EventArgs e)
		{

		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

	    protected override void Authorize()
        {
	    	CSContext context = CSContext.Current;
			ArrayList sections = CommunityServer.Galleries.Galleries.GetGalleries(true,false); //ignore permissions = false);
			sections = Sections.FilterByAccessControl(sections,Permission.Post,context.User);
			if(sections == null || sections.Count == 0)
			{
				Status.Success = false;
				Status.Text = CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Photos_NoSectionsExist");
				Status.Visible = true;

				SectionList1.Visible = false;
			}
		}

	}
}
